use data_struct_by_rust::arry::soulution_arry;
use data_struct_by_rust::stack::soulution_stack::MinStack;
use data_struct_by_rust::stack::soulution_stack;
use data_struct_by_rust::stack::slise_windows_value;
use data_struct_by_rust::hash_map;
use data_struct_by_rust::list;


#[cfg(test)]
mod solution_test{

    use super::*;

    #[test]
    fn test_soulution_arry()
    {
        soulution_arry::solution_arry_test();
    }
}



#[cfg(test)]
mod stack_test{

    use super::*;

    #[test]
    fn test_soulution_stack()
    {
        let mut new_stack = MinStack::new();
        let mut a;

        new_stack.push(-2);
        new_stack.push(0);
        new_stack.push(-3);

        a = new_stack.get_min();
        print!("the min is {}\n",a);

        new_stack.pop();

        a = new_stack.top();
        print!("the top is {}\n",a);

        a = new_stack.get_min();
        print!("the min is {}\n",a);

    }

    #[test]
    fn is_vaild()
    {
        let s = "{}()[]";

        let res = soulution_stack::parenthese_is_vaild(s.to_string());

        print!("the result is {}\n",res);
    }

    #[test]
    fn sliding_window()
    {
        let nums = vec![1,2,-2,4,-23,1,88];
        let res = slise_windows_value::max_sliding_window(nums, 3);
        print!("res {:?}\n",res);

    }


}



#[cfg(test)]
mod hash_map_test{

    use super::*;

    #[test]
    fn hash_map1_two_sum()
    {
        let nums = vec![1,2,3,4,5,6];
        let target  = 3;

        let a = hash_map::hash_map1::two_sum(nums, target);

        println!("a is {:?}", a);
    }


    #[test]
    fn group_anagrams1()
    {
        let strs = vec!["eat", "tea", "tan", "ate", "nat", "bat"];
        let res = hash_map::hash_map_group_anagrams::group_anagrams(strs);
        println!("result is {:#?}",res);

    }

    fn vec_str_to_vec_string(strs: Vec<&str>) -> Vec<String> {  
        strs.into_iter().map(|s| s.to_string()).collect()  
    }  

    #[test]
    fn group_anagrams_new_test()
    {
        let strs = vec!["eat", "tea", "tan", "ate", "nat", "bat"];

        let string = vec_str_to_vec_string(strs);

        let res = hash_map::hash_map_group_anagrams::group_anagrams_new(string);

        println!("result is {:#?}",res);
    }

    #[test]
    fn group_anagrams_new2_test()
    {
        let strs = vec!["eat", "tea", "tan", "ate", "nat", "bat"];

        let string = vec_str_to_vec_string(strs);

        let res = hash_map::hash_map_group_anagrams::group_anagrams_new_2(string);

        println!("result is {:#?}",res);
    }


}



mod list_test{
    use super::*;

    #[test]
    fn list_reserve_test()
    {

        let mut link_list = list::LinkedList::new();
       

        link_list.append(1);
        link_list.append(2);
        link_list.append(3);
        link_list.append(4);

        link_list.print();

     let list_resver =  list::list_node::Solution::reverse_list(link_list.head);
     
     println!("{:#?}",list_resver);
    }

}



fn main() {
    
    soulution_arry::solution_arry_test();
   
}

